package com.example.dorm1_demo.mapper;

import com.example.dorm1_demo.entity.User;
import org.apache.ibatis.annotations.*;
@Mapper
public interface UserMapper {
    @Insert("INSERT INTO user(username, password, email, phone, role) VALUES(#{username}, #{password}, #{email}, #{phone}, #{role})")
    int insert(User user);
    @Select("SELECT * FROM user WHERE username = #{username}")
    User selectByUsername(String username);
    @Select("SELECT * FROM user WHERE email = #{email}")
    User selectByEmail(String email);
    @Select("SELECT * FROM user WHERE phone = #{phone}")
    User selectByPhone(String phone);
    @Update("UPDATE user SET password = #{newPassword} WHERE username = #{username}")
    int updatePassword(@Param("username") String username, @Param("newPassword") String newPassword);
}